package pro.lingwu.station.dto.db;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.sql.Date;
import java.time.LocalDate;

/**
 * @author @lingwu
 * @date created in 2021/11/15
 */
@Getter
@Setter
@ToString
@ApiModel(value = "User")
public class User {

    public User() {
        this.reg_date = Date.valueOf(LocalDate.now());
        this.score = 0L;
    }

    public User(String account, String password,
                String avatar, String nickname,
                String phone, Long score,
                Date reg_date, String email) {
        this.account = account;
        this.password = password;
        this.avatar = avatar;
        this.nickname = nickname;
        this.phone = phone;
        this.score = score;
        this.reg_date = reg_date;
        this.email = email;
    }

    public User(String account, String password,
                String avatar, String nickname, String phone, String email) {
        this();
        this.account = account;
        this.password = password;
        this.avatar = avatar;
        this.nickname = nickname;
        this.phone = phone;
        this.email = email;
    }

    @NotNull
    @Size(min = 8, max = 15)
    @Pattern(regexp = "[0-9a-zA-Z]{10,15}")
    private String account;

    @NotNull
    @ApiModelProperty("SHA-512加密的密码")
    private String password;

    private String avatar;

    @NotNull
    private String nickname;

    private String phone;
    private Long score = 0L;
    private Date reg_date = Date.valueOf(LocalDate.now());

    @Email
    private String email;

}
